﻿//**********************************************************
//Copyright(C)2010 By 波特商网公司 版权所有。
//
//文件名：
//文件功能：登录设置Form
//
//创建标识：齐李平 || 2011-03-24
//
//修改标识：
//修改描述：
//**********************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Hmc.IM.Client.Properties;

namespace Hmc.IM.Client
{
    /// <summary>
    /// 登录设置Form
    /// </summary>
    public partial class LoginSettingForm : Form
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public LoginSettingForm()
        {
            InitializeComponent();
            this.panelTop.MouseDown += new MouseEventHandler(panelTop_MouseDown);
            this.panelTop.MouseUp += new MouseEventHandler(panelTop_MouseUp);
            this.panelTop.MouseMove += new MouseEventHandler(panelTop_MouseMove);
        }

        #region 头部Panel移动事件

        /// <summary>
        /// 移动事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void panelTop_MouseMove(object sender, MouseEventArgs e)
        {
            int _x = 0;
            int _y = 0;
            if (isMouseDown)
            {
                Point pt = Control.MousePosition;
                _x = mouseOffset.X - pt.X;
                _y = mouseOffset.Y - pt.Y;

                this.Location = new Point(FormLocation.X - _x, FormLocation.Y - _y);
            }
        }

        /// <summary>
        /// 鼠标弹起
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void panelTop_MouseUp(object sender, MouseEventArgs e)
        {
            isMouseDown = false;
        }

        /// <summary>
        /// 鼠标按下
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void panelTop_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                isMouseDown = true;
                FormLocation = this.Location;
                mouseOffset = Control.MousePosition;
            }
        }

        
        private bool isMouseDown = false;
        private Point FormLocation;     //form的location
        private Point mouseOffset;      //鼠标的按下位置

        
        #endregion


        /// <summary>
        /// 关闭
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pbClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        #region 关闭按钮鼠标事件

        /// <summary>
        /// 关闭按钮移入事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pbClose_MouseEnter(object sender, EventArgs e)
        {
            pbClose.Image = Resources.login_x_;
        }

        /// <summary>
        /// 关闭按钮移出事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pbClose_MouseLeave(object sender, EventArgs e)
        {
            pbClose.Image = Resources.login_x;
        } 

        #endregion

        /// <summary>
        /// 关闭事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pictureBox3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        #region 最小化按钮事件

        /// <summary>
        /// 最小化点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pbMin_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        /// <summary>
        /// 最小化鼠标移入事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pbMin_MouseEnter(object sender, EventArgs e)
        {
            pbMin.Image = Resources.login_min_current;
        }

        /// <summary>
        /// 最小化鼠标移出事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pbMin_MouseLeave(object sender, EventArgs e)
        {
            pbMin.Image = Resources.login_min;
        } 

        #endregion

        /// <summary>
        /// 加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoginSettingForm_Load(object sender, EventArgs e)
        {
            this.TransparencyKey = this.BackColor; 
        }

        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("该功能暂未开放！请继续关注新版本！");
            this.Close();
        }

    }
}
